home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00403_Constructors for cleaning FT indexes.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  8.9 KB  |  287 lines

  1. on hAllCheckforPlurals
  2.   hCheckforPlurals("FT_ENCY_S", 1)
  3.   hCheckforPlurals("FT_ENCY_S2", 1)
  4.   hCheckforPlurals("FT_ENCY_T", 1)
  5.   hCheckforPlurals("FT_ENCY_U", 1)
  6.   hCheckforPlurals("FT_ENCY_V", 1)
  7.   hCheckforPlurals("FT_ENCY_W", 1)
  8.   hCheckforPlurals("FT_ENCY_X", 1)
  9.   hCheckforPlurals("FT_ENCY_Y", 1)
  10.   hCheckforPlurals("FT_ENCY_Z", 1)
  11. end
  12.  
  13. on hCheckforPlurals pTxtFile, pNumberofFiles
  14.   hputmsg(">hCheckforPlurals begins.")
  15.   if pNumberofFiles > 1 then
  16.     set vFTindex to value(hReadAll(pTxtFile, pNumberofFiles))
  17.   else
  18.     set vFTindex to value(hReadIt(pTxtFile))
  19.   end if
  20.   hputmsg(">hCheckforPlurals please wait.........")
  21.   set vNewList to [:]
  22.   set vListtoDelete to []
  23.   repeat with vCountCastMem = 1 to count(vFTindex)
  24.     set vFTword to getPropAt(vFTindex, vCountCastMem)
  25.     set vValue to value(getAt(vFTindex, vCountCastMem))
  26.     set vCheck to vFTword & "s"
  27.     set vPluralVAL to getaProp(vFTindex, vCheck)
  28.     if voidp(vPluralVAL) then
  29.       set vCheck to vFTword & "es"
  30.       set vPluralVAL to getaProp(vFTindex, vCheck)
  31.       if voidp(vPluralVAL) then
  32.         if char the number of chars in vFTword of vFTword = "y" then
  33.           set vCheck to char 1 to the number of chars in vFTword - 1 of vFTword & "ies"
  34.           set vPluralVAL to getaProp(vFTindex, vCheck)
  35.         end if
  36.       end if
  37.     end if
  38.     if vPluralVAL <> 0 then
  39.       repeat with x = 1 to count(vPluralVAL)
  40.         set vThat to getPropAt(vPluralVAL, x)
  41.         set vThis to getAt(vPluralVAL, x)
  42.         set vDELETEME to getPos(vFTindex, vPluralVAL)
  43.         set vIsAMatch to getaProp(vValue, vThat)
  44.         if vIsAMatch <> 0 then
  45.           set vMatchProp to string(vThis) & "," & string(vIsAMatch)
  46.           set vThis to vMatchProp
  47.         end if
  48.         sort(vValue)
  49.         setaProp(vValue, vThat, vThis)
  50.         set vPos to 0
  51.       end repeat
  52.     end if
  53.     addProp(vNewList, vFTword, vValue)
  54.     if vDELETEME <> 0 then
  55.       add(vListtoDelete, vDELETEME)
  56.     end if
  57.     set vDELETEME to 0
  58.   end repeat
  59.   if vListtoDelete <> 0 then
  60.     set vFinallist to [:]
  61.     set vcounter to 0
  62.     hputmsg("Deleting NOW! wait a minute")
  63.     repeat with vX = 1 to count(vNewList)
  64.       set vNewFTword to getPropAt(vNewList, vX)
  65.       set vNewValue to value(getAt(vNewList, vX))
  66.       set vNotThisOne to getOne(vListtoDelete, vX)
  67.       if vNotThisOne = 0 then
  68.         addProp(vFinallist, vNewFTword, vNewValue)
  69.         hputmsg("adding" && vNewFTword)
  70.       else
  71.         hputmsg("                   Deleting" && vNewFTword)
  72.       end if
  73.       set vNotThisOne to 0
  74.     end repeat
  75.     writeIt(string(vFinallist), pTxtFile & "_NEW")
  76.   end if
  77. end
  78.  
  79. on hCheckforPluralsInCast pFirstCast, pLastCast
  80.   hputmsg(">hCheckforPlurals begins.")
  81.   repeat with vcastNum = pFirstCast to pLastCast
  82.     set vFTindex to value(field vcastNum)
  83.     hputmsg(">hCheckforPlurals please wait.........")
  84.     set vNewList to [:]
  85.     set vListtoDelete to []
  86.     repeat with vCountCastMem = 1 to count(vFTindex)
  87.       set vFTword to getPropAt(vFTindex, vCountCastMem)
  88.       set vValue to value(getAt(vFTindex, vCountCastMem))
  89.       set vCheck to vFTword & "s"
  90.       set vPluralVAL to getaProp(vFTindex, vCheck)
  91.       if voidp(vPluralVAL) then
  92.         set vCheck to vFTword & "es"
  93.         set vPluralVAL to getaProp(vFTindex, vCheck)
  94.         if voidp(vPluralVAL) then
  95.           if char the number of chars in vFTword of vFTword = "y" then
  96.             set vCheck to char 1 to the number of chars in vFTword - 1 of vFTword & "ies"
  97.             set vPluralVAL to getaProp(vFTindex, vCheck)
  98.           end if
  99.         end if
  100.       end if
  101.       if vPluralVAL <> 0 then
  102.         repeat with x = 1 to count(vPluralVAL)
  103.           set vThat to getPropAt(vPluralVAL, x)
  104.           set vThis to getAt(vPluralVAL, x)
  105.           set vDELETEME to getPos(vFTindex, vPluralVAL)
  106.           set vIsAMatch to getaProp(vValue, vThat)
  107.           if vIsAMatch <> 0 then
  108.             set vMatchProp to string(vThis) & "," & string(vIsAMatch)
  109.             set vThis to vMatchProp
  110.           end if
  111.           sort(vValue)
  112.           setaProp(vValue, vThat, vThis)
  113.           set vPos to 0
  114.           hputmsg(x)
  115.         end repeat
  116.       end if
  117.       addProp(vNewList, vFTword, vValue)
  118.       if vDELETEME <> 0 then
  119.         add(vListtoDelete, vDELETEME)
  120.       end if
  121.       set vDELETEME to 0
  122.     end repeat
  123.     if vListtoDelete <> 0 then
  124.       set vFinallist to [:]
  125.       set vcounter to 0
  126.       hputmsg("Deleting NOW! wait a minute")
  127.       repeat with vX = 1 to count(vNewList)
  128.         set vNewFTword to getPropAt(vNewList, vX)
  129.         set vNewValue to value(getAt(vNewList, vX))
  130.         set vNotThisOne to getOne(vListtoDelete, vX)
  131.         if vNotThisOne = 0 then
  132.           addProp(vFinallist, vNewFTword, vNewValue)
  133.         else
  134.           hputmsg("                   Deleting" && vNewFTword)
  135.         end if
  136.         set vNotThisOne to 0
  137.       end repeat
  138.       set vName to the name of cast vcastNum
  139.       put string(vFinallist) into field vcastNum
  140.       set the name of cast vcastNum to vName & "_NEW"
  141.     end if
  142.   end repeat
  143. end
  144.  
  145. on hReadAll pTxtFile, pNumberofFiles
  146.   set gTheFile to [:]
  147.   set gEntireNameList to [:]
  148.   set vThisFile to [:]
  149.   repeat with x = 1 to pNumberofFiles
  150.     set vThisFile to value(hReadIt(pTxtFile & x))
  151.     if not objectp(vThisFile) then
  152.       hputmsg(" ******* list is messed up it is not a list *******")
  153.     end if
  154.     repeat with p = 1 to count(vThisFile)
  155.       addProp(gEntireNameList, getPropAt(vThisFile, p), getAt(vThisFile, p))
  156.     end repeat
  157.   end repeat
  158.   hputmsg("hReadAll a file named " & pTxtFile & x & "******************" & RETURN)
  159.   return gEntireNameList
  160. end
  161.  
  162. on hputtheseinCAST whichmode
  163.   repeat with thischar = charToNum("A") to charToNum("D")
  164.     set alph to numToChar(thischar)
  165.     hReadinFt("FT" & whichmode & alph)
  166.   end repeat
  167. end
  168.  
  169. on hCheckallforSingles whichmode
  170.   repeat with thischar = charToNum("A") to charToNum("Z")
  171.     set alph to numToChar(thischar)
  172.     set var to "FT" & whichmode & alph
  173.     hCheckforSingles(var)
  174.   end repeat
  175. end
  176.  
  177. on hCheckforSingles thisCastMem
  178.   set temp to [:]
  179.   set thisList to [:]
  180.   set listDups to [:]
  181.   set temp to the text of cast thisCastMem
  182.   set temp to value(temp)
  183.   sort(temp)
  184.   repeat with p = 1 to count(temp)
  185.     set vProp to getPropAt(temp, p)
  186.     set vValue to getAt(temp, p)
  187.     if count(vValue) > 1 then
  188.       addProp(thisList, vProp, vValue)
  189.       next repeat
  190.     end if
  191.   end repeat
  192.   sort(thisList)
  193.   set the text of cast thisCastMem to string(thisList)
  194. end
  195.  
  196. on hReadinFt readthisName
  197.   set gTheFile to [:]
  198.   set gReadObject to FileIO(mnew, "read", the pathName & readthisName)
  199.   set vTheFile to gReadObject(mReadLine)
  200.   gReadObject(mdispose)
  201.   set the text of cast readthisName to string(vTheFile)
  202.   hputmsg("Read a file named " & readthisName & "******************" & RETURN)
  203. end
  204.  
  205. on hReadFileoffHD readthisName, thiscastnumber
  206.   set vTheFile to [:]
  207.   set gReadObject to FileIO(mnew, "read", the pathName & readthisName)
  208.   hputmsg("the pathname&thisName =" & the pathName & readthisName)
  209.   set vTheFile to gReadObject(mReadLine)
  210.   gReadObject(mdispose)
  211.   set the text of cast thiscastnumber to string(vTheFile)
  212.   set the name of cast thiscastnumber to string(readthisName)
  213.   hputmsg("Read a file named " & readthisName & "******************" & RETURN)
  214. end
  215.  
  216. on hRunAll
  217.   hReadFileoffHD("FT_ENCY_X" & "_NEW", 866)
  218.   hReadFileoffHD("FT_ENCY_Y" & "_NEW", 867)
  219.   hReadFileoffHD("FT_ENCY_Z" & "_NEW", 868)
  220. end
  221.  
  222. on hSortThisCast pStart, pStop
  223.   repeat with j = pStart to pStop
  224.     set lk to [:]
  225.     set lk to value(field j)
  226.     if not objectp(lk) then
  227.       beep()
  228.       put "Field" && j && "is not a legal list."
  229.       abort()
  230.     end if
  231.     put "Got field" && j && "with" && count(lk) && "items."
  232.     sort(lk)
  233.     put lk into field j
  234.     put "...sorted and replaced"
  235.   end repeat
  236.   put "hSortThisCast complete."
  237. end
  238.  
  239. on hsimplyverify pStart, pStop
  240.   repeat with j = pStart to pStop
  241.     set lk to value(field j)
  242.     if not objectp(lk) then
  243.       beep()
  244.       put "Field" && j && "is not a legal list."
  245.       next repeat
  246.     end if
  247.     put "Field" && j && "has" && count(lk) && "items" && the name of cast j
  248.   end repeat
  249.   put "hsimplyverify complete."
  250. end
  251.  
  252. on hShowCastList pFirstCast, pLastCast
  253.   repeat with i = pFirstCast to pLastCast
  254.     if not (the name of cast i contains "blank") then
  255.       set vNumofChar to the size of cast i
  256.       set vTemp to the number of cast i & "   " & the name of cast i & "   " & vNumofChar
  257.       set gHold to gHold & RETURN & vTemp
  258.     end if
  259.   end repeat
  260.   put gHold
  261. end
  262.  
  263. on hshowfirstlast pFirstCast, pLastCast
  264.   repeat with i = pFirstCast to pLastCast
  265.     set k to value(field i)
  266.     if not objectp(k) then
  267.       put "Cast" && the name of cast i && "is not a list"
  268.       next repeat
  269.     end if
  270.     if count(k) > 0 then
  271.       put "Cast" && i && the name of cast i && getPropAt(k, 1) && getPropAt(k, count(k))
  272.     end if
  273.   end repeat
  274.   put "finished"
  275. end
  276.  
  277. on hFTTest pWhat
  278.   set t to the ticks
  279.   put "Running..."
  280.   repeat with i = 1 to 1000
  281.     set Lpointer to hCapitalize(char 1 of pWhat)
  282.     hSubdivideFTpointer(Lpointer, pWhat)
  283.   end repeat
  284.   set t to the ticks - t
  285.   put "That took" && t && "ticks."
  286. end
  287.